import { request } from '../request';

export function fetchUseGroupList() {
  return request.get<Admin.UserGroup[]>(`/admin/userGroupList`);
}

export function fetchInsertOrUpdateUserGroup(userGroup: Admin.UserGroup) {
  return request.post<boolean>(`/admin/insertOrUpdateUserGroup`, userGroup);
}

export function fetchDeleteUserGroup(userGroup: Admin.UserGroup) {
  return request.post<boolean>(`/admin/deleteUserGroup`, userGroup);
}

export function fetchUserInfoListByUserGroup(userGroupName: string) {
  return request.get<Admin.UserInfo[]>(`/admin/userInfoListByUserGroupName?userGroupName=${userGroupName}`);
}

export function fetchUserInfoListBySerarch(userId: string, userName: string) {
  return request.get<Admin.UserInfo[]>(`/admin/userInfoListBySerarch?userId=${userId}&userName=${userName}`);
}

export function fetchInsertOrUpdateUserInfo(userInfo: Admin.UserInfo) {
  return request.post<boolean>(`/admin/insertOrUpdateUserInfo`, userInfo);
}

export function fetchDeleteUserInfo(userInfo: Admin.UserInfo) {
  return request.post<boolean>(`/admin/deleteUserInfo`, userInfo);
}

export function fetchUserGroupMenuAll(uiName: string, userGroupName: string) {
  return request.get<Admin.UserGroupMenu[]>(`/admin/userGroupMenuAll?uiName=${uiName}&userGroupName=${userGroupName}`);
}

export function fetchInsertUserGroupMenu(userGroupMenu: Admin.UserGroupMenu) {
  return request.post<boolean>(`/admin/insertUserGroupMenu`, userGroupMenu);
}

export function fetchDeleteUserGroupMenu(userGroupMenu: Admin.UserGroupMenu) {
  return request.post<boolean>(`/admin/deleteUserGroupMenu`, userGroupMenu);
}

export function fetchAddFavoriteMenu(favoriteMenu: Admin.FavoriteMenu) {
  return request.post<boolean>(`/admin/addFavoriteMenu`, favoriteMenu);
}

export function fetchFavoriteMenuList(userid: string, uiname: string) {
  return request.get<Admin.Menu[]>(`/admin/favoriteMenuList?userid=${userid}&uiname=${uiname}`);
}
